integer
A 64-bit signed integer type, ranging from -2^63
to (2^63)-1
, supporting a standard complement of numerical operations.
Since
0.6.0
Constructors
Construct an integer object by parsing a signed text representation of an integer.
Base prefixes are not supported, so one must write e.g. integer('CAFE', 16)
rather than integer('0xCAFE')
.
Case is ignored, i.e. integer('CAFE', 16)
and integer('cafe', 16)
are equivalent.
Supported radixes are from 2 to 36 (inclusive).
Construct an integer from a decimal, with any fractional part truncated (i.e. rounding toward 0).
Functions
Parse an unsigned hexadecimal text representation of an integer.
Base prefixes are not supported, so one must write e.g. integer.from_hex('CAFE')
rather than integer.from_hex('0xCAFE')
.
Case is ignored, i.e. integer.from_hex('CAFE')
and integer.from_hex('cafe')
are equivalent.
Returns the greater of this integer and a big_integer
value; i.e. value
if value
is greater than this integer, or this integer otherwise.
Returns the greater of this integer and a decimal
value; i.e. value
if value
is greater than this integer, or this integer otherwise.
Returns the greater of this integer and another integer value; i.e. value
if value
is greater than this integer, or this integer otherwise.
Returns the lesser of this integer and a big_integer
value; i.e. value
if value
is less than this integer, or this integer otherwise.
Returns the lesser of this integer and a decimal
value; i.e. value
if value
is less than this integer, or this integer otherwise.
Returns the lesser of this integer and another integer value; i.e. value
if value
is less than this integer, or this integer otherwise.
Parse an unsigned hexadecimal text representation of an integer.
Base prefixes are not supported, so one must write e.g. integer.from_hex('CAFE')
rather than integer.from_hex('0xCAFE')
.
Case is ignored, i.e. integer.from_hex('CAFE')
and integer.from_hex('cafe')
are equivalent.
Raise this integer to the power of the given exponent. SQL compatible.
Fails on integer overflow; so if results outside integer range are expected, first convert to big_integer
(e.g. with integer.to_big_integer()
or big_integer(integer)
) and then use big_integer.pow()
.
Note that:
the exponent cannot be negative
if the exponent is 0, the result is 1
if the exponent is 1, the result is the original value
Convert this integer to a base-10 text representation.
Convert this integer to a text representation with the specified radix.
Does not include a base prefix in the output, i.e. integer(25).to_text(16)
returns 19
rather than 0x19
.
Supported radixes are from 2 to 36 (inclusive).
Convert this integer to a big integer.
Convert this integer to a decimal.
Convert this integer to a base-10 text representation.
Convert this integer to a text representation with the specified radix.
Does not include a base prefix in the output, i.e. integer(25).to_text(16)
returns 19
rather than 0x19
.
Supported radixes are from 2 to 36 (inclusive).